package com.cluster.quartz;

import java.util.Date;

import javax.annotation.PostConstruct;

import org.quartz.SchedulerException;
import org.quartz.SimpleTrigger;
import org.quartz.Trigger;
import org.quartz.impl.triggers.SimpleTriggerImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.quartz.JobDetailFactoryBean;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
import org.springframework.stereotype.Component;

//@Component("schedulerHelper")
public class SchedulerHelper {
	
//	private Scheduler scheduler;
	
	@Autowired
	public SchedulerFactoryBean baseQuartzScheduler;
//	@Autowired
//	private org.quartz.JobDetail jobDetail;
	@Autowired
	private JobDetailFactoryBean jobDetail;
	@Autowired
	private Trigger trigger;
	
	
	private static final String CONFIG_FILE = "quartz.properties";
	
//	@PostConstruct
	public void init() throws SchedulerException {
		// 创建一个定时器工厂
//		StdSchedulerFactory sf = new StdSchedulerFactory();
		// 初始化quartz.properties配置文件
//		sf.initialize(Thread.currentThread().getContextClassLoader().getResource(CONFIG_FILE).getFile());
//		sf.initialize();
		
//		scheduler = sf.getScheduler();
//		baseQuartzScheduler.getScheduler().getJobDetail(arg0)
//		Trigger trigger1 = new SimpleTrigger("myTrigger",Scheduler.DEFAULT_GROUP,new Date(),null,SimpleTrigger.REPEAT_INDEFINITELY,6000L);
		long l = 6000L;
		Trigger trigger1 = new SimpleTriggerImpl("myTrigger","asd",
				new Date(),
				null,
                SimpleTrigger.REPEAT_INDEFINITELY,
                l);
//		jobDetail.getObject()
//		baseQuartzScheduler.scheduleJob(jobDetail.getObject(), trigger1);
//		baseQuartzScheduler.start();
		
	}
}
